package com.smart.speaker.websocket.tool;

import com.alibaba.dashscope.tools.FunctionDefinition;
import com.alibaba.dashscope.tools.ToolFunction;
import com.google.gson.JsonObject;
import com.smart.speaker.websocket.ChatState;
import org.springframework.stereotype.Component;

@Component(value = "exit_game_tool")
public class ExitGameTool implements Tool {

    private final ToolFunction function;

    public ExitGameTool() {
        JsonObject parameters = new JsonObject();
        parameters.addProperty("type", "object");
        function = ToolFunction.builder().function(FunctionDefinition.builder().name("exit_game_tool")
                .description("当用户想要退出游戏时可以调用该方法")
                .parameters(parameters).build()).build();
    }

    @Override
    public ToolResp call(String params) {
        return new ToolResp(Type.RESPONSE, ChatState.NORMAL, "好的，已退出");
    }

    @Override
    public ToolFunction getFunction() {
        return function;
    }
}
